<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <home-page></home-page>
  </div>
  <script src="./vue.global.js"></script>
  <script>
    const { createApp } = Vue;
    const app = createApp();
    const CommonTitle = {
      template: `
        <div>
          <header>
            <slot name="header"></slot>  
          </header>  
          <main>
            <slot :a="a" :b="b"></slot>  
          </main>
          <footer>
            <slot :a="c" name="footer"></slot>  
          </footer>
        </div>
      `,
      data() {
        return {
          a: '传给默认插槽',
          b: '也传给默认插槽',
          c: '传给footer插槽'
        }
      },
    }
    const HomePage = {
      template: `
        <div>
          <h1>首页</h1>  
          <common-title>
            <template #default="data">
              <button>按钮{{data.a}}</button>  
               <h2>这也是默认内容{{data.b}}</h2>  
            </template>
            <template v-slot:header>
              <p>这是头部</p>  
              <span>这是头部</span>
            </template>
            <template #footer="data">
              <h3>传给footer{{data.a}}</h3>
            </template>
          </common-title>
          
        </div>
      `,
      components: {
        CommonTitle
      }
    }

    app.component('HomePage', HomePage)
    app.mount('#app')
  </script>
</body>
</html>